@include('admin.header')
<style>
  .search_product {
    max-height:248px;
    overflow-y: scroll;
  }
  .search_product > .item {
    width:80px;
    margin-right:5px;
    float:left;
  }
  .search_product > .item img {
    height:80px;
  }
  .search_product > .item .name {
    height:20px;
    overflow:hidden;
  }

  .editor {
    width: 60%;
  }
</style>
<div class="margin-top-20">
  <form method="post" class="form-horizontal js-ajax-form direct_item_add_form" action="/globalexchange/direct_item_add_submit" novalidate="novalidate" enctype ="multipart/form-data">
    <fieldset>
      <div class="control-group"><label class="control-label">套餐名称</label>
        <div class="controls">
          <input type="text" name="name" value="{{$data->name or ''}}"><span class="form-required" >*</span>
        </div>
      </div>
      <div class="control-group"><label class="control-label">套餐图片</label>
        <div class="controls">
          @if(!empty($data->image))
            <img src="{{$data->image or ''}}" style="height:80px;" />
          @endif
          <input type="file" name="image" onchange="upload_image(this)" />
        </div>
      </div>
      <div class="control-group"><label class="control-label">数量</label>
        <div class="controls">
          <input type="number" name="total" value="{{$data->total or ''}}"><span class="form-required" >*</span>
        </div>
      </div>
      <div class="control-group"><label class="control-label">单品总价格</label>
        <div class="controls">
          <input type="number" name="amount" value="{{$data->amount or ''}}"><span class="form-required" >*</span>
        </div>
      </div>
      <div class="control-group"><label class="control-label">商品属性</label>
        <div class="controls">
          <input type="text" name="sku" value="{{$data->sku or ''}}" placeholder="默认"><span class="form-required" >*</span>
        </div>
      </div>
      <!-- 富文本编辑器 -->
      <div class="control-group"><label class="control-label">商品详情</label>
        <div class="controls">
          <textarea id="editor" class="editor" name="details">{{$data->details or ''}}</textarea>
        </div>
      </div>
    </fieldset>
    <div class="form-actions">
      <input type="hidden" name="id" value="{{$data->id or 0}}" />
      <button type="submit" class="btn btn-primary js-ajax-submit">保存</button>
    </div>

    <input type="hidden" name="direct_id" value="{{$direct_id}}" />
  </form>
</div>

<!-- 引入富文本编辑器依赖的JS文件 -->
<script type="text/javascript" charset="utf-8" src="/static/js/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/static/js/ueditor/1.4.3/ueditor.all.min.js"> </script>
<script type="text/javascript" charset="utf-8" src="/static/js/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>

<script>
	$(function () {
    //实例化富文本编辑器
    var ue = UE.getEditor('editor');

    //添加/编辑
		$('.direct_item_add_form').submit(function(){
			var $t = $(this),action=$t.attr('action'),data = $t.serialize();
			post(action,data,function(data){
				_alert('处理成功',function(){
					parent.location.reload();
					parent.layer.close(parent.layer_open2);
        });
      });
			return false;
    });
	});
</script>